#include "graphsupport/graph/operation/MakeSymmOperation.h"

#include <algorithm>
#include <iostream>

void MakeSymmOperation::makeSymm( Graph & graph )
{
	int n = graph.getVertexCount();
	Graph::AdjMatrixType adjMatr = graph.getAdjacentMatrixArr();
	for ( int i = 0; i < n; i++ )
	{
		for ( int j = 0; j < n; j++ )
		{
			if ( graph.existsEdge( i, j ) )
			{
				Graph::AdjCoefType cost = std::min( adjMatr[i][j], adjMatr[j][i] );
				adjMatr[i][j] = cost;
				adjMatr[j][i] = cost;
			}
		}
	}
}

void MakeSymmOperation::applyTo( Graph & graph, IOperationSettings & genSettings )
{
	makeSymm( graph );
}
